import localActions from '@/action/main/local';
import networkActions from '@/action/main/network';

const state = {
    project: {},
    service: {},
    token: false,
    titlebar: {},
};
const getters = {};
const mutations = {};
const actions = {
    setMainOptions(context, param) {
        context.state.project = param.project;
        context.state.token = param.token ? param.token : '';
        context.state.service = param.service;
        if (param.service == 'root') {
            window.action = localActions;
        } else {
            window.action = networkActions;
        };
    },
    setProjectDetail(context, param) {
        context.state.project.title = param.title;
        context.state.project.description = param.description;
        if (context.state.service.title) {
            context.state.titlebar.updateTitle(`${context.state.service.title} - ${context.state.project.title}`);
        } else {
            context.state.titlebar.updateTitle(`${context.state.project.title}`);
        };
    },
    setTitleBar(context, titlebar) {
        context.state.titlebar = titlebar;
    },
};

export default {
    namespaced: true,
    state,
    getters,
    mutations,
    actions
}